home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_13_11 / phillip2 / fixt.c < prev    next >
C/C++ Source or Header  |  1993-06-07  |  2KB  |  99 lines

  1.  
  2.        /***********************************************
  3.        *
  4.        *   file d:\cips\fixt.c
  5.        *
  6.        *   Functions: This file contains
  7.        *      main
  8.        *
  9.        *   Purpose:
  10.        *      This file contains the main calling
  11.        *      routine to fix thresholded images.
  12.        *
  13.        *   External Calls:
  14.        *      gin.c - get_image_name
  15.        *      numcvrt.c - get_integer
  16.        *                  int_convert
  17.        *      tiff.c - read_tiff_header
  18.        *
  19.        *
  20.        *   Modifications:
  21.        *      24 October 1992 - created
  22.        *
  23.        *************************************************/
  24.  
  25. #include "cips.h"
  26.  
  27.  
  28.  
  29. short the_image[ROWS][COLS];
  30. short out_image[ROWS][COLS];
  31. unsigned long histogram[GRAY_LEVELS+1];
  32. long slopes[GRAY_LEVELS+1];
  33.  
  34. main(argc, argv)
  35.    int argc;
  36.    char *argv[];
  37. {
  38.  
  39.    char name[80], name2[80], response[80];
  40.  
  41.    int  a, b, count, i, ie, il, j, k, le, length, ll,
  42.         peak1, peak2, size,
  43.         t, type, v, width;
  44.    short background, hi, low, object, value;
  45.  
  46.  
  47.    struct   tiff_header_struct image_header;
  48.  
  49.    my_clear_text_screen();
  50.  
  51.    if(argc < 4){
  52.     printf("\n\nfixt in-file out-file value ");
  53.     printf("\n");
  54.     exit(0);
  55.    }
  56.  
  57.    strcpy(name, argv[1]);
  58.    strcpy(name2, argv[2]);
  59.    value = atoi(argv[3]);
  60.  
  61.    il = 1;
  62.    ie = 1;
  63.    ll = ROWS+1;
  64.    le = COLS+1;
  65.  
  66.    read_tiff_header(name, &image_header);
  67.  
  68.    length = (ROWS-10 + image_header.image_length)/ROWS;
  69.    width  = (COLS-10 +image_header.image_width)/COLS;
  70.    count  = 1;
  71.    printf("\nlength=%d  width=%d", length, width);
  72.  
  73.    create_file_if_needed(name, name2, out_image);
  74.  
  75.      for(i=0; i<length; i++){
  76.         for(j=0; j<width; j++){
  77.           printf("\nrunning %d of %d", count, length*width);
  78.           count++;
  79.              read_tiff_image(name, the_image,
  80.                   il+i*ROWS, ie+j*COLS,
  81.                   ll+i*ROWS, le+j*COLS);
  82.  
  83.                  for(a=0; a<ROWS; a++){
  84.                     for(b=0; b<COLS; b++){
  85.                         if(the_image[a][b] != value)
  86.                             the_image[a][b] = 100;
  87.                      }
  88.                  }
  89.  
  90.              write_array_into_tiff_image(name2, the_image,
  91.                               il+i*ROWS,
  92.                               ie+j*COLS,
  93.                               ll+i*ROWS,
  94.                               le+j*COLS);
  95.         }  /* ends loop over i */
  96.      }  /* ends loop over j */
  97.  
  98. }  /* ends main */
  99.